// pages/components/video_play/video_play.js
var startPoint;
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    showdapei: {
      type: Number,
      value:0
    },
    video_url: {
      type: String,
      value:''
    },
    buttonTop: {
      type: Number,
      value:0
    },
    buttonLeft: {
      type: Number,
      value:0
    },

  },

  /**
   * 组件的初始数据
   */
  data: {

  },



  /**
   * 组件的方法列表
   */
  methods: {
    playvideo(e) {
      var videoContext = wx.createVideoContext('myVideo', this);
      videoContext.requestFullScreen();
    },

    //视频移动
    buttonStart: function (e) {
      startPoint = e.touches[0]
    },
    buttonMove: function (e) {
      // 获取当前窗口的宽度
      wx.getSystemInfoSync().windowHeight; // 获取当前窗口的高度
      wx.getSystemInfoSync().windowWidth;
      var endPoint = e.touches[e.touches.length - 1];
      var translateX = endPoint.clientX - startPoint.clientX;
      var translateY = endPoint.clientY - startPoint.clientY;
      startPoint = endPoint;
      var buttonTop = this.data.buttonTop + translateY;
      var buttonLeft = this.data.buttonLeft + translateX;
      this.setData({
        buttonTop: buttonTop,
        buttonLeft: buttonLeft
      })
    },
    buttonEnd: function (e) {
      console.log(e)
    },
    //关闭视频窗口
    closevideo() {
      //点击关闭的时候吧url设置为空，即可关闭视频窗口
      this.setData({
        video_url: ''
      })
    },
    //视频结束触发
    bindended(e) {
      this.setData({
        video_url: ''
      })
    },
    //视频播放错误出发
    videoErrorCallback() {
      console.log("我是播放错误出发");
    },
  }
})


// //视频移动
// buttonStart: function(e) {
//   startPoint = e.touches[0]
// },
// buttonMove: function(e) {
//   // 获取当前窗口的宽度
//   wx.getSystemInfoSync().windowHeight // 获取当前窗口的高度
//   wx.getSystemInfoSync().windowWidth
//   var endPoint = e.touches[e.touches.length - 1]
//   var translateX = endPoint.clientX - startPoint.clientX
//   var translateY = endPoint.clientY - startPoint.clientY
//   startPoint = endPoint
//   var buttonTop = this.data.buttonTop + translateY
//   var buttonLeft = this.data.buttonLeft + translateX
//   this.setData({
//     buttonTop: buttonTop,
//     buttonLeft: buttonLeft
//   })
// },
// buttonEnd: function(e) {

// },